package com.itheima.fanshe;

import com.itheima.domain.Student;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/*
方法 调对象
 */
public class Demo11 {

    public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        Class<Student> clazz = Student.class;
        Student student = clazz.getDeclaredConstructor().newInstance();
        Method eat = clazz.getDeclaredMethod("eat");
        eat.setAccessible(true);
        Object invoke = eat.invoke(student);
        student.study();
        System.out.println(invoke);

        Method dance = clazz.getDeclaredMethod("dance", int.class);
        Object invoke1 = dance.invoke(student, 20);
        System.out.println(invoke1);


    }
}
